<!DOCTYPE html>
<#assign f=JspTaglibs["http://www.casic304.cn/f"] />
<#assign SourceDept = JspTaglibs["http://www.casic304.cn/SourceDept"]/>
<head>
    <meta charset="utf-8">
    <title>QC小组注册信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>

</head>
<body class="listBody">
<div class="qbdms-list">
    <div class="layui-table-view-body">
        <table id="wQbdQcGroupTable" lay-filter="wQbdQcGroupTable"></table>
    </div>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="wQbdQcGroupHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <@f.a alias="xzan_qcxzzc302" css="layui-btn layui-btn-sm fillBtn" event="add">
                <span>新增</span>
            </@f.a>
            <@f.a alias="scan_acxzzc302" css="layui-btn layui-btn-sm" event="delete">
                <span>删除</span>
            </@f.a>
          <a class="layui-btn layui-btn-sm" lay-event="export">
                <span>导出</span>
            </a>
        </div>
        <form class="layui-form" action="" lay-filter="wQbdQcGroupQueryForm" >
            <div class="layui-form-body selch">
                <div class="table-top-filter layui-row">
                        <@SourceDept.dept css="layui-input filter-value"/>
                        <div class="qbdms-listForm">
                            <label class="layui-form-label">注册编号</label>
                                <div class="layui-input-block">
                                    <input type="text" class="layui-input filter-value" name="Q_registernum_SL" placeholder="请输入"/>
                                </div>
                        </div>

                        <div class="qbdms-listForm">
                            <label class="layui-form-label">小组名称</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input filter-value" name="Q_groupname_SL" placeholder="QC小组名称"/>
                            </div>
                        </div>

                        <div class="qbdms-listForm">
                            <label class="layui-form-label">注册开始时间</label>
                            <div class="layui-input-block">
                                <input type="text" readonly="readonly" class="layui-input start_time4 filter-value" name="Q_beginRegisterdate_DL" placeholder="请输入"/>
                            </div>
                        </div>

                    <div class="qbdms-listForm">
                        <label class="layui-form-label">注册结束时间</label>
                        <div class="layui-input-block">
                            <input type="text" readonly="readonly" class="layui-input end_time4 filter-value" name="Q_endRegisterdate_DG" placeholder="请输入" />
                        </div>
                    </div>

                    <div class="qbdms-listForm">
                        <label class="layui-form-label">课题名称</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value" name="Q_subjectname_SL" placeholder="课题名称"/>
                        </div>
                    </div>


                </div>
                <div class="selchBtn">
                    <a class="layui-btn layui-btn-sm fillBtn" lay-event="query">
                        <span>查询</span>
                    </a>
                    <div class="layui-btn-group">
                        <button type="button" class="layui-btn layui-btn-sm" lay-event="clears" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_refresh"></i>
                        </button>
                        <button type="button" class="layui-btn layui-btn-sm screenParent" lay-event="screen" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_downarrow screen"></i>
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>

</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdQcGroupRightToolsBar">
    {{# if(('${rolealis}'=="bpm_qnzl"  && d.allowEdit && '${userId}'==d.createBy) || ('${rolealis}'=="bpm_zlzhzly"  && d.allowEdit)){ }}
         <@f.a alias="xgan_qcxzzc302" css="RightBtn" event="edit">编辑</@f.a>
    {{#  } }}

    <@f.a alias="xqan_qcxzzc302" event="particulars" css="RightBtn">详情</@f.a>

    {{# if(d.allowDel && '${userId}'==d.createBy){ }}
    <@f.a alias="scan_acxzzc302" css="RightBtn" event="del">删除</@f.a>
    {{#  } }}
</script>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','table', 'form', 'common','publicMethods','jquery','layer','propsHandle'], function () {
        var table = layui.table;
        var form = layui.form;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;
        var propsHandle = layui.propsHandle;
        var defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle();  // 实例化模板功能部分
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });
        common.tableSort('wQbdQcGroupTable');

        var tableH=publicMethods.tabHeight();

        var cols = '${cols}';
        var currentSystemLevel = "${currentSystemLevel}";

        var orderCols = [{type: 'checkbox', fixed: 'left'},{field: 'sn', type: 'numbers', title: '序号', fixed: 'left', minWidth: 90}];
        var fillDeptCols = [];

        var commonCols = [
            { field: 'groupname', title: 'QC小组名称',  minWidth: 150 }
            , { field: 'secret', title: '密级', sort: false, sortname: 'secret', minWidth: 120}
            , { field: 'registerdept', title: '注册单位', minWidth: 140 }
            , { field: 'registernum', title: '注册编号',  minWidth: 140 }

            , { field: 'subjectname', title: '课题名称', minWidth: 140 }
            , { field: 'groupleader', title: '组长', minWidth: 90 }
            , {
                field: 'registerdate', title: '注册时间', minWidth: 140, templet: function (d) {
                    return publicMethods.timeData(d.registerdate);
                }
            }
            , {field: 'flowStatusStr', title: '状态', sort: false, sortname: 'flowStatusStr', minWidth: 140}
        ];

        var hideCols = [
            { field: 'id', title: '主键', sort: true, sortname: 'id', minWidth: 120 ,hide: true}
            , { field: 'fillman', title: '填写人', sort: true, sortname: 'fillman', minWidth: 140 ,hide: true}
            , { field: 'fillmanaccount', title: '填写人的账号', sort: true, sortname: 'fillmanaccount', minWidth: 150 ,hide: true}
            , { field: 'filldeptid', title: '填写部门id', sort: true, sortname: 'filldeptid', minWidth: 150 ,hide: true}
            , { field: 'returnmsg', title: '错误信息', sort: true, sortname: 'returnmsg', minWidth: 140 ,hide: true}
            , { field: 'filldeptHospital', title: '填写部门院', sort: true, sortname: 'filldeptHospital', minWidth: 150 ,hide: true}
            , { field: 'tenantId', title: '租户Id', sort: true, sortname: 'tenantid', minWidth: 140 ,hide: true}
            , { field: 'createBy', title: '创建人', sort: true, sortname: 'createby', minWidth: 140 ,hide: true}
            , {
                field: 'createTime', title: '创建时间', sort: true, hide: true,sortname: 'createtime', minWidth: 140, templet: function (d) {
                    return publicMethods.timeData(d.createTime);
                }
            }
            , { field: 'updateBy', title: '更新人', sort: true, sortname: 'updateby', minWidth: 140 ,hide: true}
            , {
                field: 'updateTime', title: '更新时间', sort: true, hide: true,sortname: 'updatetime', minWidth: 140, templet: function (d) {
                    return publicMethods.timeData(d.updateTime);
                }
            }
            , { field: 'belongdeptname', title: '所属单位(用于数据纵向筛选）', sort: true, sortname: 'belongdeptname', minWidth: 190 ,hide: true}
            , { field: 'reportReason', title: '中间件操作失败原因', sort: true, sortname: 'report_reason', minWidth: 180 ,hide: true}
            , { field: 'filldate', title: '填报日期', sort: true, sortname: 'filldate', minWidth: 140 ,hide: true}


            , {
                field: 'finishdate', title: '计划完成时间', sort: true, hide: true,sortname: 'finishdate', minWidth: 150, templet: function (d) {
                    return publicMethods.timeData(d.finishdate);
                }
            }
            , { field: 'groupMembers', title: '小组成员', sort: true, sortname: 'group_members', minWidth: 140,hide: true }
            , { field: 'peopleamount', title: '人数', sort: true, sortname: 'peopleamount', minWidth: 90 ,hide: true }
            , { field: 'linktel', title: '联系电话', sort: true, sortname: 'linktel', minWidth: 140 ,hide: true }
            , { field: 'economicPerformance', title: '带来的经济效益（万元）', sort: true, sortname: 'economic_performance',align:'right', minWidth: 200,hide: true ,templet: function (d) {
                    if (d.economicPerformance != null){
                        return '<span style="color: #F07878">'+d.economicPerformance+'</span>';
                    }else {
                        return '<span style="color: #F07878">'+0+'</span>';
                    }
                } }
            , { field: 'targeteffect', title: '目标及预期效果', sort: true, sortname: 'targeteffect', minWidth: 160 ,hide: true }
            , { field: 'remark', title: '备注', sort: true, sortname: 'remark', minWidth: 90 ,hide: true }
            , { field: 'registerdeptid', title: '注册部门ID', sort: true, sortname: 'registerdeptid', minWidth: 150 ,hide: true }
            , { field: 'linkman', title: '联系人', sort: true, sortname: 'linkman', minWidth: 140 ,hide: true }
            , { field: 'groupCategory', title: '小组类别', sort: true, sortname: 'group_category', minWidth: 140 ,hide: true }
        ];

        var diyCols = [];

        var manageCols =[{
            fixed: 'right',
            title: '管理',
            toolbar: '#wQbdQcGroupRightToolsBar',
            minWidth: 160
        }];

        var totalCols = [];
        totalCols = totalCols.concat(orderCols).concat(fillDeptCols).concat(commonCols).concat(hideCols).concat(diyCols).concat(manageCols);

        //第一个实例
        table.render({
            elem: '#wQbdQcGroupTable'
            ,height:tableH
            ,url: serverPath.qbdmsPath + '/qbdms/wQbdQcGroup/list'
            ,page: publicMethods.pageFun()
            , limit: 20
            ,defaultToolbar: ['']
            ,toolbar: '#wQbdQcGroupHeaderToolsBar'
            ,method: 'post'
            ,autoSort: false //是否排序
            ,cols: [cols ? JSON.parse(cols) : totalCols],done:function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input','a[lay-event=query]','.ccpui-enterSel');
            }
            ,parseData: function(res){ //res 即为原始返回的数据
                common.parseDataList(res,['groupleader','finishdate','fConferencepersonnel','groupMembers','groupCategory','peopleamount','linkman'
                    ,'economicPerformance','targeteffect','remark']);
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.data //解析数据列表
                };
            }
        });
        hideZcdw();
        dateReflash()
        //list页面初始化展开按钮tips展示（展开按钮类名）
        publicMethods.tipsAuto('.screen')
        //筛选条件初始化（页面表格的Id，是否初始化（true、false））
        common.initScreenTop('wQbdQcGroupTable',true);
        function dateReflash() {
            publicMethods.reflashDate({startName:'.start_time1',endName:'.end_time1'});
            publicMethods.reflashDate({startName:'.start_time2',endName:'.end_time2'});
            publicMethods.reflashDate({startName:'.start_time3',endName:'.end_time3'});
            publicMethods.reflashDate({startName:'.start_time4',endName:'.end_time4'});
            publicMethods.reflashDate({startName:'.start_time5',endName:'.end_time5'});
        }

        function reflashQuery(isClear) {
            common.tableConditionRender("wQbdQcGroupTable","wQbdQcGroupQueryForm",{where: {}}, isClear, false, 20);
            setOrg();
            hideZcdw();
        }

        table.on('toolbar(wQbdQcGroupTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            switch (obj.event) {
                case 'add':
                    window.location.href = serverPath.qbdmsPath + "/qbdms/wQbdQcGroup/view/add";
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array+=data[i].id+",";
                    }
                    delFun(data,array);
                    break;
                case 'export':
                    function open(url , param){
                        var curUrl = url;
                        layer.open({
                            type: 2,
                            area: ['700px', '520px'],
                            title: ['自定义导出', 'font-size:14px;'],
                            content: serverPath.qbdmsPath + '/qbdms/wQbdQcGroup/view/export',
                            btnAlign: 'c',
                            skin: 'qbdms-layerFormBtn',
                            btn: ['确定', '取消'],
                            yes: function(index, layero){
                                url = curUrl;
                                var iframeWin = window["layui-layer-iframe" + index];
                                var data = iframeWin.getData();
                                if(data){
                                    url = url + "?data=" + JSON.stringify(data) + param;
                                    window.location.href = encodeURI(url)
                                }
                            }
                        });
                    }

                    if (data.length == 0) {
                        layer.confirm(publicMethods.confirmStyle('还没有选择，是否导出全部?'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var url = serverPath.qbdmsPath + '/qbdms/wQbdQcGroup/exportData';
                            var param = "";
                            $("form[lay-filter='wQbdQcGroupQueryForm']").find(".filter-value").each(function(i,value) {
                                param += "&"+this.name+"="+this.value
                            });
                            open(url , param);
                        });
                    } else {
                        layer.confirm(publicMethods.confirmStyle('确定导出吗?'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var url = serverPath.qbdmsPath + '/qbdms/wQbdQcGroup/exportData';
                            open(url , "&id="+ids);
                        });
                    }
                    break;
                case "import":
                    common.importInit('wQbdQcGroupTable',"/qbdms/wQbdQcGroup/importData",true,"/importTemplates/QC小组注册.xlsx");
                    dateReflash();
                    break;
                case "query":
                    reflashQuery(false);
                    dateReflash();
                    break;
                case "clears":
                    reflashQuery(true);
                    dateReflash();
                    break;
                case "screen":
                    common.initScreenTop('wQbdQcGroupTable');
                    dateReflash();
                    form.render();
                    break;
                case "report":
                    var ids = "";
                    for (var i = 0; i < data.length; i++) {
                        ids += data[i].id + ",";
                    }

                    //业务表名,勾选数据主键,流程key,table标签lay-filter属性值,form标签lay-filter属性值,是否允许重复上报,页面所在包名,流程定义id
                    common.report("W_QBD_QC_GROUP", ids, "plantToHospital", "wQbdQcGroupTable", "wQbdQcGroupQueryForm", false, "wQbdQcGroup", "plantToHospital:1:72d05d40362249118c5453aa60c6da90");
                    dateReflash();
                    break;
            };
        });

        table.on('tool(wQbdQcGroupTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                    layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "edit":
                    window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdQcGroup/view/add?id='+data.id;
                    break;
                case "particulars":
                    window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdQcGroup/view/particulars?id='+data.id;
                    break;
                case "del":
                    delFun(data,data.id);
                    break;
            }
        });

        function setOrg() {
            var org = eval('${org}');
            var orgHtml = "<option value=\"\"></option>";
            $.each(org, function (index, obj) {
                orgHtml += "  <option  orgid='" + obj.CODE + "' value='" + obj.CODE + "'  >" + obj.ORGNAME + "</option>";
            });
            $("select[name='Q_registerdeptid_S']").html(orgHtml);
        }

        setOrg();

        table.on('sort()', function(obj){
            reflashQuery(false);
            dateReflash();
        });

        function delFun(data,id) {
            if (data.length === 0) {
                layer.confirm(publicMethods.confirmStyle("请先选择一行数据!"),{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm(publicMethods.confirmStyle('确定删除当前数据吗?'),{title: false,skin: 'confirm-class'},function (index) {
                    layer.close(index);
                    $.ajax({
                        url: serverPath.qbdmsPath + "/qbdms/wQbdQcGroup/del",
                        type: "post",
                        data: {id:id},
                        dataType: 'json',
                        success: function (data) {
                            layer.confirm(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.confirm(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }

        window.Initialization = function () {
            dateReflash();
            reflashQuery(true);
        };

        function hideZcdw(){
            if("PLANTLEVEL" == currentSystemLevel){
                // 隐藏搜索 责任单位
                $("#zcdw").removeClass();
                $("#zcdw").addClass("layui-hide");
                form.render();
            }
        }

        /*刷新时间控件*/
        dateReflash();
        common.tableSort("wQbdQcGroupTable");
        
    });
</script>
</body>
</html>